package com.irs.controller;

import com.irs.pojo.BuildingUtil;

import com.irs.service.BuildingUtilService;
import com.irs.util.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class BuildUtilController {
    @Autowired
    BuildingUtilService buildingUtilDao;
    /**
     * 跳转到列表页面
     * @return
     */
    @GetMapping("/build/govillage")//数据库中的href
        public String golist() {

        return "page/build/buildUtilList";
    }

    @GetMapping("/build/village/list")//与url一致
    @ResponseBody
    public Object villageList() {
        List<BuildingUtil> buildingUtilList = buildingUtilDao.select(new BuildingUtil());
        //返回JSON
        return  ResultUtil.ok(buildingUtilList,buildingUtilList.size());
    }

}
